<html>
<head>
<title>test.py</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #859900;}
.s1 { color: #e8e6ff;}
.s2 { color: #ffb2ff;}
.s3 { color: #0cff00; font-weight: bold;}
.s4 { color: #fffb00; font-style: italic;}
.s5 { color: #2aa198;}
</style>
</head>
<body bgcolor="#34324a">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
test.py</font>
</center></td></tr></table>
<pre><span class="s0">import </span><span class="s1">tkinter</span>

<span class="s0">from </span><span class="s1">Attriabte.DTO </span><span class="s0">import </span><span class="s1">BasicWidgetDto, ColorHoverWidgetDto, MoveAnimalDto, LayoutDto</span>
<span class="s0">from </span><span class="s1">Entiy.WordGroup </span><span class="s0">import </span><span class="s1">WordGroup</span>
<span class="s0">from </span><span class="s1">View.MainWindow </span><span class="s0">import </span><span class="s1">MainWindow</span>
<span class="s0">from </span><span class="s1">View.WindowComponent.BasicHoverLabel </span><span class="s0">import </span><span class="s1">BasicHoverLabel</span>
<span class="s0">from </span><span class="s1">View.WindowComponent.BodyFrame.Main </span><span class="s0">import </span><span class="s1">MainFrame</span>
<span class="s0">from </span><span class="s1">View.WindowComponent.BodyFrame.ManagerFrame </span><span class="s0">import </span><span class="s1">ManagerFrame</span>
<span class="s0">from </span><span class="s1">View.WindowComponent.ColorHoverLabel </span><span class="s0">import </span><span class="s1">ColorHoverLabel</span>
<span class="s0">from </span><span class="s1">View.WindowComponent.Layout.LayoutSide </span><span class="s0">import </span><span class="s1">LayoutSide</span>
<span class="s0">from </span><span class="s1">View.WindowThread.BasicAnimal </span><span class="s0">import </span><span class="s1">MoveAnimal</span>
<span class="s0">from </span><span class="s1">View.WindowThread.ThreadManager </span><span class="s0">import </span><span class="s1">ThreadManager</span>
<span class="s0">import </span><span class="s1">customtkinter</span>

customtkinter.set_default_color_theme<span class="s2">(</span><span class="s3">&quot;green&quot;</span><span class="s2">)</span>

<span class="s0">def </span><span class="s1">frame_sroller</span><span class="s2">()</span><span class="s1">:</span>
    <span class="s0">import </span><span class="s1">tkinter </span><span class="s0">as </span><span class="s1">tk</span>
    <span class="s0">from </span><span class="s1">tkscrollframe </span><span class="s0">import </span><span class="s1">ScrollFrame</span>

    root = tk.Tk<span class="s2">()</span>
    <span class="s1">sf = ScrollFrame</span><span class="s2">(</span><span class="s1">root</span><span class="s2">)</span>

    <span class="s1">frame = sf.viewPort  </span><span class="s4"># is important</span>

    # add some widget to frame sf
    <span class="s0">for </span><span class="s1">i </span><span class="s0">in </span><span class="s1">range</span><span class="s2">(</span><span class="s5">20</span><span class="s2">)</span><span class="s1">:</span>
        tk.Label<span class="s2">(</span><span class="s1">frame, text=</span><span class="s3">f&quot;text in line </span><span class="s0">{</span><span class="s1">i</span><span class="s0">}</span><span class="s3">&quot;</span><span class="s2">)</span><span class="s1">.pack</span><span class="s2">()</span>
    <span class="s1">print</span><span class="s2">(</span><span class="s1">sf</span><span class="s2">)</span>
    <span class="s1">sf.pack</span><span class="s2">()</span>
    <span class="s1">root.mainloop</span><span class="s2">()</span>

<span class="s0">def </span><span class="s1">MainFrame_Test</span><span class="s2">()</span><span class="s1">:</span>
    app = MainWindow<span class="s2">()</span>

    <span class="s1">Config = ColorHoverWidgetDto</span><span class="s2">(</span><span class="s1">text=</span><span class="s3">'主页'</span><span class="s1">, hover_fg=</span><span class="s3">'green'</span><span class="s1">, hover_bg=</span><span class="s3">'black'</span><span class="s2">)</span>
    <span class="s1">Config2 = ColorHoverWidgetDto</span><span class="s2">(</span><span class="s1">text=</span><span class="s3">'单词管理'</span><span class="s1">, hover_fg=</span><span class="s3">'green'</span><span class="s1">, hover_bg=</span><span class="s3">'black'</span><span class="s2">)</span>
    <span class="s1">label = []</span>
    frame = []
    layoutSide = LayoutSide<span class="s2">(</span><span class="s1">app, label, frame, LayoutDto</span><span class="s2">(</span><span class="s1">color_style=</span><span class="s3">'Zebra'</span><span class="s1">, hover_children=</span><span class="s0">True</span><span class="s2">))</span>
    <span class="s1">frame.append</span><span class="s2">(</span><span class="s1">MainFrame</span><span class="s2">(</span><span class="s1">layoutSide,</span><span class="s0">False</span><span class="s2">)</span><span class="s1">.get</span><span class="s2">())</span>
    <span class="s1">frame.append</span><span class="s2">(</span><span class="s1">ManagerFrame</span><span class="s2">(</span><span class="s1">layoutSide,</span><span class="s0">True</span><span class="s2">)</span><span class="s1">.get</span><span class="s2">())</span>
    <span class="s1">print</span><span class="s2">(</span><span class="s1">frame</span><span class="s2">)</span>
    <span class="s1">label.append</span><span class="s2">(</span><span class="s1">ColorHoverLabel</span><span class="s2">(</span><span class="s1">layoutSide.frame_side, Config</span><span class="s2">))</span>
    <span class="s1">label.append</span><span class="s2">(</span><span class="s1">ColorHoverLabel</span><span class="s2">(</span><span class="s1">layoutSide.frame_side, Config2</span><span class="s2">))</span>
    <span class="s1">layoutSide.put</span><span class="s2">()</span>
    <span class="s1">app.show</span><span class="s2">()</span>


<span class="s0">def </span><span class="s1">LayoutSide_Test</span><span class="s2">()</span><span class="s1">:</span>
    app = MainWindow<span class="s2">()</span>
    <span class="s1">list_label = []</span>
    frame = []
    <span class="s4"># 创建layout label的dto</span>

    <span class="s1">Config = ColorHoverWidgetDto</span><span class="s2">(</span><span class="s1">text=</span><span class="s3">'标签'</span><span class="s1">, hover_fg=</span><span class="s3">'green'</span><span class="s1">, hover_bg=</span><span class="s3">'black'</span><span class="s2">)</span>
    <span class="s1">Config2 = ColorHoverWidgetDto</span><span class="s2">(</span><span class="s1">text=</span><span class="s3">'标签2'</span><span class="s1">, hover_fg=</span><span class="s3">'green'</span><span class="s1">, hover_bg=</span><span class="s3">'red'</span><span class="s2">)</span>

    <span class="s4"># 创建layout</span>
    <span class="s1">layoutDto = LayoutDto</span><span class="s2">(</span><span class="s1">color_style=</span><span class="s3">&quot;Zebra&quot;</span><span class="s1">, hover_children=</span><span class="s0">True</span><span class="s2">)</span>
    <span class="s1">print</span><span class="s2">(</span><span class="s1">layoutDto.hover_children</span><span class="s2">)</span>

    <span class="s1">layout = LayoutSide</span><span class="s2">(</span><span class="s1">app.MainWidow, list_label, frame, layoutDto</span><span class="s2">)</span>

    <span class="s4"># frame与frame 的装饰</span>
    <span class="s1">frame1 = layout.Data. getFrameInstance</span><span class="s2">(</span><span class="s1">BasicWidgetDto</span><span class="s2">(</span><span class="s1">bg=</span><span class="s3">'green'</span><span class="s2">))</span>
    <span class="s1">frame2 = layout.Data. getFrameInstance</span><span class="s2">(</span><span class="s1">BasicWidgetDto</span><span class="s2">(</span><span class="s1">bg=</span><span class="s3">'red'</span><span class="s2">))</span>
    <span class="s1">frame3 = layout.Data. getFrameInstance</span><span class="s2">(</span><span class="s1">BasicWidgetDto</span><span class="s2">(</span><span class="s1">bg=</span><span class="s3">'blue'</span><span class="s2">))</span>
    <span class="s1">tkinter.Label</span><span class="s2">(</span><span class="s1">frame1, text=</span><span class="s3">'1'</span><span class="s1">, bg=</span><span class="s3">'red'</span><span class="s2">)</span><span class="s1">.place</span><span class="s2">(</span><span class="s1">x=</span><span class="s5">0</span><span class="s1">, y=</span><span class="s5">0</span><span class="s2">)</span>
    <span class="s1">tkinter.Label</span><span class="s2">(</span><span class="s1">frame2, text=</span><span class="s3">'2'</span><span class="s1">, bg=</span><span class="s3">'red'</span><span class="s2">)</span><span class="s1">.place</span><span class="s2">(</span><span class="s1">x=</span><span class="s5">0</span><span class="s1">, y=</span><span class="s5">0</span><span class="s2">)</span>
    <span class="s1">tkinter.Label</span><span class="s2">(</span><span class="s1">frame3, text=</span><span class="s3">'3'</span><span class="s1">, bg=</span><span class="s3">'red'</span><span class="s2">)</span><span class="s1">.place</span><span class="s2">(</span><span class="s1">x=</span><span class="s5">0</span><span class="s1">, y=</span><span class="s5">0</span><span class="s2">)</span>
    <span class="s1">frame.append</span><span class="s2">(</span><span class="s1">frame1</span><span class="s2">)</span>
    <span class="s1">frame.append</span><span class="s2">(</span><span class="s1">frame2</span><span class="s2">)</span>
    <span class="s1">frame.append</span><span class="s2">(</span><span class="s1">frame3</span><span class="s2">)</span>

    <span class="s4"># 创建llabel|</span>
    <span class="s1">colorHoverLabel = ColorHoverLabel</span><span class="s2">(</span><span class="s1">layout.frame_side, Config</span><span class="s2">)</span>
    <span class="s1">colorHoverLabel2 = ColorHoverLabel</span><span class="s2">(</span><span class="s1">layout.frame_side, Config2</span><span class="s2">)</span>

    <span class="s4"># 将label加入list_label</span>
    <span class="s1">list_label.append</span><span class="s2">(</span><span class="s1">colorHoverLabel</span><span class="s2">)</span>
    <span class="s1">list_label.append</span><span class="s2">(</span><span class="s1">colorHoverLabel2</span><span class="s2">)</span>

    <span class="s4"># 布置布局</span>
    <span class="s1">layout.put</span><span class="s2">()</span>

    <span class="s1">app.show</span><span class="s2">()</span>


<span class="s0">def </span><span class="s1">ColorHoverLabel_Test</span><span class="s2">()</span><span class="s1">:</span>
    app = MainWindow<span class="s2">()</span>
    <span class="s1">window = app.MainWidow</span>
    config = ColorHoverWidgetDto<span class="s2">(</span><span class="s3">&quot;测试文本&quot;</span><span class="s2">)</span>
    <span class="s1">basicHoverLabel = ColorHoverLabel</span><span class="s2">(</span><span class="s1">window, config</span><span class="s2">)</span>
    <span class="s1">basicHoverLabel.get</span><span class="s2">()</span><span class="s1">.pack</span><span class="s2">()</span>
    <span class="s1">app.show</span><span class="s2">()</span>


<span class="s0">def </span><span class="s1">BasicHoverLabel_Test</span><span class="s2">()</span><span class="s1">:</span>
    app = MainWindow<span class="s2">()</span>
    <span class="s1">window = app.MainWidow</span>
    config = BasicWidgetDto<span class="s2">(</span><span class="s3">&quot;测试文本&quot;</span><span class="s2">)</span>
    <span class="s1">basicHoverLabel = BasicHoverLabel</span><span class="s2">(</span><span class="s1">window, config</span><span class="s2">)</span>
    <span class="s1">basicHoverLabel.get</span><span class="s2">()</span><span class="s1">.pack</span><span class="s2">()</span>
    <span class="s1">app.show</span><span class="s2">()</span>


<span class="s0">def </span><span class="s1">MoveAnimal_Text</span><span class="s2">()</span><span class="s1">:</span>
    app = MainWindow<span class="s2">()</span>
    <span class="s1">win = app.MainWidow</span>

    mat = MoveAnimalDto<span class="s2">(</span>
        <span class="s1">from_site=</span><span class="s2">(</span><span class="s5">0</span><span class="s1">, </span><span class="s5">0</span><span class="s2">)</span><span class="s1">,</span>
        to_site=<span class="s2">(</span><span class="s5">100</span><span class="s1">, </span><span class="s5">200</span><span class="s2">)</span><span class="s1">,</span>
        frame=<span class="s5">100</span>
    <span class="s2">)</span>

    <span class="s1">con = BasicWidgetDto</span><span class="s2">(</span><span class="s3">&quot;测试文本&quot;</span><span class="s2">)</span>
    <span class="s1">label = ColorHoverLabel</span><span class="s2">(</span><span class="s1">win, con</span><span class="s2">)</span><span class="s1">.get</span><span class="s2">()</span>
    <span class="s1">moveAnimal = MoveAnimal</span><span class="s2">(</span><span class="s1">win, label, mat</span><span class="s2">)</span>
    <span class="s1">ThreadManager</span><span class="s2">(</span><span class="s1">moveAnimal</span><span class="s2">)</span>

    <span class="s1">app.show</span><span class="s2">()</span>

<span class="s0">def </span><span class="s1">models_word</span><span class="s2">()</span><span class="s1">:</span>
    wg = WordGroup<span class="s2">()</span>
    <span class="s1">wg.new_group</span><span class="s2">(</span><span class="s3">&quot;Hello&quot;</span><span class="s2">)</span>
    <span class="s1">print</span><span class="s2">(</span><span class="s1">wg.group_register</span><span class="s2">)</span>
    <span class="s1">print</span><span class="s2">(</span><span class="s1">wg.load_group</span><span class="s2">(</span><span class="s3">&quot;test2&quot;</span><span class="s1">, </span><span class="s0">True</span><span class="s2">))</span>
    <span class="s1">print</span><span class="s2">(</span><span class="s1">wg.get_all_word</span><span class="s2">())</span>

<span class="s0">def </span><span class="s1">table_test</span><span class="s2">()</span><span class="s1">:</span>
    <span class="s0">from </span><span class="s1">pandastable </span><span class="s0">import </span><span class="s1">Table</span>
    app = tkinter.Tk<span class="s2">()</span>
    <span class="s4"># assuming parent is the frame in which you want to place the table</span>
    <span class="s1">pt = Table</span><span class="s2">(</span><span class="s1">parent=app</span><span class="s2">)</span>
    <span class="s1">pt.importCSV</span><span class="s2">(</span><span class="s3">&quot;./resource/word.xlsx&quot;</span><span class="s2">)</span>
    <span class="s1">pt.show</span><span class="s2">()</span>
    <span class="s1">app.mainloop</span><span class="s2">()</span>

<span class="s0">if </span><span class="s1">__name__ == </span><span class="s3">'__main__'</span><span class="s1">:</span>
    MainFrame_Test<span class="s2">()</span>
</pre>
</body>
</html>